package top.yifengxiner.blockchain.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.yifengxiner.blockchain.mapper.EducatorMapper;
import top.yifengxiner.blockchain.pojo.entity.Educator;
import top.yifengxiner.blockchain.pojo.vo.BRegisterBody;
import top.yifengxiner.blockchain.service.EducatorService;
import top.yifengxiner.common.core.pojo.entity.SysUser;
import top.yifengxiner.system.service.SysUserService;

/**
 * @author ：baixiao
 * @date ：Created in 2021/5/12 10:03
 * @description：教育者服务
 * @modified By：
 * @version: 0.0.1$
 */
@Service
public class EducatorServiceImpl implements EducatorService
{
    @Autowired
    private SysUserService userService;

    @Autowired
    private EducatorMapper educatorMapper;


    @Override
    public SysUser getIdByName(String name)
    {
        return null;
    }

    @Override
    public Educator getEducatorById(Long id)
    {
        return null;
    }

    @Override
    public int setEducator(BRegisterBody registerBody)
    {
        SysUser user = userService.selectUserByUsername(registerBody.getSubject());
        Educator educator = new Educator();
        educator.setEducatorId(user.getUserId());
        educator.setEducatorName(user.getUserName());
        educator.setPassword(user.getPassword());
        int res = educatorMapper.insert(educator);
        return res;
    }

    @Override
    public Educator getEducatorByName(String name)
    {
        return educatorMapper.selectOne(new QueryWrapper<Educator>().eq("educator_name",name));
    }
}
